import {
  ApiProperty,
  IntersectionType,
  OmitType,
  PartialType,
  PickType,
} from '@nestjs/swagger';
import { IsInt, IsString } from 'class-validator';
import { FindListDto } from 'src/modules/find-list.dto';

export class DictDataDto {
  @IsInt()
  @ApiProperty({ type: Number, description: 'id' })
  readonly id: number;

  @ApiProperty({ type: String, description: '字典标签' })
  public dict_label: string;

  @ApiProperty({ type: String, description: '字典键值' })
  public dict_value: string;

  @ApiProperty({ type: String, description: '字典类型' })
  public dict_type: string;

  @ApiProperty({ type: Number, description: '字典排序' })
  public sort: number;

  @ApiProperty({ type: String, description: '状态' })
  public status: string;

  @IsString()
  @ApiProperty({
    type: String,
    description: '备注',
    default: null,
  })
  readonly remark: string;

  @ApiProperty({ type: Date, description: '创建时间', default: null })
  readonly created_date: Date;

  @IsString()
  @ApiProperty({
    type: String,
    description: '创建人',
    default: null,
  })
  readonly created_by: string;

  @ApiProperty({ type: Date, description: '更新时间', default: null })
  readonly updated_date: Date;

  @IsString()
  @ApiProperty({
    type: String,
    description: '更新人',
    default: null,
  })
  readonly updated_by: string;
}

export class FindDictDataListDto extends IntersectionType(
  PartialType(FindListDto),
  PartialType(PickType(DictDataDto, ['dict_label', 'dict_type'] as const)),
) {}

export class CreateDictDataDto extends PartialType(
  OmitType(DictDataDto, ['id', 'created_date', 'updated_date']),
) {}

export class UpdateDictDataDto extends PartialType(
  OmitType(DictDataDto, ['created_date', 'updated_date']),
) {}
